home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume16 / plp / part03 < prev    next >
Encoding:
Internet Message Format  |  1988-09-22  |  52.8 KB

  1. Path: uunet!bbn.com!rsalz
  2. From: rsalz@uunet.uu.net (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v16i016:  Public lineprinter spooler package, Part03/16
  5. Message-ID: <1069@fig.bbn.com>
  6. Date: 14 Sep 88 20:14:44 GMT
  7. Lines: 1745
  8. Approved: rsalz@uunet.UU.NET
  9.  
  10. Submitted-by: papowell@julius.cs.umn.edu
  11. Posting-number: Volume 16, Issue 16
  12. Archive-name: plp/part03
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then unpack
  16. # it by saving it into a file and typing "sh file".  To overwrite existing
  17. # files, type "sh file -c".  You can also feed this as standard input via
  18. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  19. # will see the following message at the end:
  20. #        "End of archive 3 (of 16)."
  21. # Contents:  Copyright LICENSE doc/PLP/LICENSE filters/vdmp.c man/lpq.1
  22. #   man/lprm.1 src/errormsg.c src/lprm.c src/remote_ops.c
  23. #   src/sendmail.c src/setup_filter.c
  24. # Wrapped by papowell@attila on Wed Aug 10 10:44:49 1988
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f 'Copyright' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'Copyright'\"
  28. else
  29. echo shar: Extracting \"'Copyright'\" \(3940 characters\)
  30. sed "s/^X//" >'Copyright' <<'END_OF_FILE'
  31. Public Line Printer (PLP) Software License Agreement
  32. X
  33. Copyright 1988 (C) Patrick Powell
  34. X
  35. Patrick Powell,
  36. Dept. of Computer Science,
  37. University of Minnesota,
  38. Minneapolis, Minnesota.
  39. Wed Apr 13 14:53:36 CDT 1988
  40. X
  41. The PLP software is available for use, and may be copied and distributed.
  42. Sale of the software without the explicit permission of the author
  43. is forbidden.
  44. X
  45. X            COPYING POLICIES
  46. X
  47. X  1. You may copy and distribute verbatim copies of PLP Software source
  48. code as you receive it, in any medium, provided that you conspicuously
  49. and appropriately publish on each file a valid copyright notice such
  50. as "Copyright (C) 1988 Patrick Powell", containing the year of
  51. last change and name of copyright holder for the file in question;
  52. keep intact the notices on all files that refer to this License
  53. Agreement and to the absence of any warranty; and give any other
  54. recipients of the PLP Software program a copy of this License Agreement
  55. along with the program.  You may charge a distribution fee for the
  56. physical act of transferring a copy.
  57. X
  58. X  2. You may modify your copy or copies of PLP Software source code or
  59. any portion of it, and copy and distribute such modifications under
  60. the terms of Paragraph 1 above, provided that you also do the following:
  61. X
  62. X    a) cause the modified files to carry prominent notices stating
  63. X    who last changed such files and the date of any change; and
  64. X
  65. X    b) cause the whole of any work that you distribute or publish,
  66. X    that in whole or in part contains or is a derivative of PLP Software
  67. X    or any part thereof, to be licensed at no charge to all third
  68. X    parties on terms identical to those contained in this License
  69. X    Agreement (except that you may choose to grant more extensive
  70. X    warranty protection to third parties, at your option).
  71. X
  72. X  3. You may not copy, sublicense, distribute or transfer PLP Software
  73. except as expressly provided under this License Agreement.  Any attempt
  74. otherwise to copy, sublicense, distribute or transfer PLP Software is void and
  75. your rights to use PLP Software under this License agreement shall be
  76. automatically terminated.  However, parties who have received computer
  77. software programs from you with this License Agreement will not have
  78. their licenses terminated so long as such parties remain in full compliance.
  79. X
  80. X  4. If you wish to incorporate parts of PLP Software into other programs
  81. whose distribution conditions are different, write to the University of
  82. Minnesota.  Donations are gratefully received.
  83. X
  84. X               NO WARRANTY
  85. X
  86. X  BECAUSE PLP SOFTWARE IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  87. NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  88. WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  89. PATRICK POWELL AND/OR OTHER PARTIES PROVIDE PLP SOFTWARE "AS IS"
  90. WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  91. BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  92. XFITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  93. AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PLP SOFTWARE
  94. PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
  95. SERVICING, REPAIR OR CORRECTION.
  96. X
  97. X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL THE UNIVERSITY OF
  98. MINNESOTA, PATRICK POWELL, AND/OR ANY OTHER PARTY WHO MAY
  99. MODIFY AND REDISTRIBUTE PLP SOFTWARE AS PERMITTED ABOVE, BE LIABLE TO YOU
  100. XFOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER
  101. SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
  102. INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
  103. BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A
  104. XFAILURE OF THE PROGRAM TO OPERATE WITH PROGRAMS NOT DISTRIBUTED BY
  105. XFREE SOFTWARE FOUNDATION, INC.) THE PROGRAM, EVEN IF YOU HAVE BEEN
  106. ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY
  107. OTHER PARTY.
  108. X
  109. X
  110. Basically:
  111. X    1. It's Free.
  112. X    2. You can give it away.
  113. X    3. If it bites you,  don't blame us!
  114. X
  115. Patrick Powell
  116. END_OF_FILE
  117. if test 3940 -ne `wc -c <'Copyright'`; then
  118.     echo shar: \"'Copyright'\" unpacked with wrong size!
  119. fi
  120. # end of 'Copyright'
  121. fi
  122. if test -f 'LICENSE' -a "${1}" != "-c" ; then 
  123.   echo shar: Will not clobber existing file \"'LICENSE'\"
  124. else
  125. echo shar: Extracting \"'LICENSE'\" \(3940 characters\)
  126. sed "s/^X//" >'LICENSE' <<'END_OF_FILE'
  127. Public Line Printer (PLP) Software License Agreement
  128. X
  129. Copyright 1988 (C) Patrick Powell
  130. X
  131. Patrick Powell,
  132. Dept. of Computer Science,
  133. University of Minnesota,
  134. Minneapolis, Minnesota.
  135. Wed Apr 13 14:53:36 CDT 1988
  136. X
  137. The PLP software is available for use, and may be copied and distributed.
  138. Sale of the software without the explicit permission of the author
  139. is forbidden.
  140. X
  141. X            COPYING POLICIES
  142. X
  143. X  1. You may copy and distribute verbatim copies of PLP Software source
  144. code as you receive it, in any medium, provided that you conspicuously
  145. and appropriately publish on each file a valid copyright notice such
  146. as "Copyright (C) 1988 Patrick Powell", containing the year of
  147. last change and name of copyright holder for the file in question;
  148. keep intact the notices on all files that refer to this License
  149. Agreement and to the absence of any warranty; and give any other
  150. recipients of the PLP Software program a copy of this License Agreement
  151. along with the program.  You may charge a distribution fee for the
  152. physical act of transferring a copy.
  153. X
  154. X  2. You may modify your copy or copies of PLP Software source code or
  155. any portion of it, and copy and distribute such modifications under
  156. the terms of Paragraph 1 above, provided that you also do the following:
  157. X
  158. X    a) cause the modified files to carry prominent notices stating
  159. X    who last changed such files and the date of any change; and
  160. X
  161. X    b) cause the whole of any work that you distribute or publish,
  162. X    that in whole or in part contains or is a derivative of PLP Software
  163. X    or any part thereof, to be licensed at no charge to all third
  164. X    parties on terms identical to those contained in this License
  165. X    Agreement (except that you may choose to grant more extensive
  166. X    warranty protection to third parties, at your option).
  167. X
  168. X  3. You may not copy, sublicense, distribute or transfer PLP Software
  169. except as expressly provided under this License Agreement.  Any attempt
  170. otherwise to copy, sublicense, distribute or transfer PLP Software is void and
  171. your rights to use PLP Software under this License agreement shall be
  172. automatically terminated.  However, parties who have received computer
  173. software programs from you with this License Agreement will not have
  174. their licenses terminated so long as such parties remain in full compliance.
  175. X
  176. X  4. If you wish to incorporate parts of PLP Software into other programs
  177. whose distribution conditions are different, write to the University of
  178. Minnesota.  Donations are gratefully received.
  179. X
  180. X               NO WARRANTY
  181. X
  182. X  BECAUSE PLP SOFTWARE IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  183. NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  184. WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  185. PATRICK POWELL AND/OR OTHER PARTIES PROVIDE PLP SOFTWARE "AS IS"
  186. WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  187. BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  188. XFITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  189. AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PLP SOFTWARE
  190. PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
  191. SERVICING, REPAIR OR CORRECTION.
  192. X
  193. X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL THE UNIVERSITY OF
  194. MINNESOTA, PATRICK POWELL, AND/OR ANY OTHER PARTY WHO MAY
  195. MODIFY AND REDISTRIBUTE PLP SOFTWARE AS PERMITTED ABOVE, BE LIABLE TO YOU
  196. XFOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER
  197. SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
  198. INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
  199. BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A
  200. XFAILURE OF THE PROGRAM TO OPERATE WITH PROGRAMS NOT DISTRIBUTED BY
  201. XFREE SOFTWARE FOUNDATION, INC.) THE PROGRAM, EVEN IF YOU HAVE BEEN
  202. ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY
  203. OTHER PARTY.
  204. X
  205. X
  206. Basically:
  207. X    1. It's Free.
  208. X    2. You can give it away.
  209. X    3. If it bites you,  don't blame us!
  210. X
  211. Patrick Powell
  212. END_OF_FILE
  213. if test 3940 -ne `wc -c <'LICENSE'`; then
  214.     echo shar: \"'LICENSE'\" unpacked with wrong size!
  215. fi
  216. # end of 'LICENSE'
  217. fi
  218. if test -f 'doc/PLP/LICENSE' -a "${1}" != "-c" ; then 
  219.   echo shar: Will not clobber existing file \"'doc/PLP/LICENSE'\"
  220. else
  221. echo shar: Extracting \"'doc/PLP/LICENSE'\" \(3940 characters\)
  222. sed "s/^X//" >'doc/PLP/LICENSE' <<'END_OF_FILE'
  223. Public Line Printer (PLP) Software License Agreement
  224. X
  225. Copyright 1988 (C) Patrick Powell
  226. X
  227. Patrick Powell,
  228. Dept. of Computer Science,
  229. University of Minnesota,
  230. Minneapolis, Minnesota.
  231. Wed Apr 13 14:53:36 CDT 1988
  232. X
  233. The PLP software is available for use, and may be copied and distributed.
  234. Sale of the software without the explicit permission of the author
  235. is forbidden.
  236. X
  237. X            COPYING POLICIES
  238. X
  239. X  1. You may copy and distribute verbatim copies of PLP Software source
  240. code as you receive it, in any medium, provided that you conspicuously
  241. and appropriately publish on each file a valid copyright notice such
  242. as "Copyright (C) 1988 Patrick Powell", containing the year of
  243. last change and name of copyright holder for the file in question;
  244. keep intact the notices on all files that refer to this License
  245. Agreement and to the absence of any warranty; and give any other
  246. recipients of the PLP Software program a copy of this License Agreement
  247. along with the program.  You may charge a distribution fee for the
  248. physical act of transferring a copy.
  249. X
  250. X  2. You may modify your copy or copies of PLP Software source code or
  251. any portion of it, and copy and distribute such modifications under
  252. the terms of Paragraph 1 above, provided that you also do the following:
  253. X
  254. X    a) cause the modified files to carry prominent notices stating
  255. X    who last changed such files and the date of any change; and
  256. X
  257. X    b) cause the whole of any work that you distribute or publish,
  258. X    that in whole or in part contains or is a derivative of PLP Software
  259. X    or any part thereof, to be licensed at no charge to all third
  260. X    parties on terms identical to those contained in this License
  261. X    Agreement (except that you may choose to grant more extensive
  262. X    warranty protection to third parties, at your option).
  263. X
  264. X  3. You may not copy, sublicense, distribute or transfer PLP Software
  265. except as expressly provided under this License Agreement.  Any attempt
  266. otherwise to copy, sublicense, distribute or transfer PLP Software is void and
  267. your rights to use PLP Software under this License agreement shall be
  268. automatically terminated.  However, parties who have received computer
  269. software programs from you with this License Agreement will not have
  270. their licenses terminated so long as such parties remain in full compliance.
  271. X
  272. X  4. If you wish to incorporate parts of PLP Software into other programs
  273. whose distribution conditions are different, write to the University of
  274. Minnesota.  Donations are gratefully received.
  275. X
  276. X               NO WARRANTY
  277. X
  278. X  BECAUSE PLP SOFTWARE IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
  279. NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
  280. WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
  281. PATRICK POWELL AND/OR OTHER PARTIES PROVIDE PLP SOFTWARE "AS IS"
  282. WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
  283. BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  284. XFITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
  285. AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PLP SOFTWARE
  286. PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
  287. SERVICING, REPAIR OR CORRECTION.
  288. X
  289. X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL THE UNIVERSITY OF
  290. MINNESOTA, PATRICK POWELL, AND/OR ANY OTHER PARTY WHO MAY
  291. MODIFY AND REDISTRIBUTE PLP SOFTWARE AS PERMITTED ABOVE, BE LIABLE TO YOU
  292. XFOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER
  293. SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
  294. INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
  295. BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A
  296. XFAILURE OF THE PROGRAM TO OPERATE WITH PROGRAMS NOT DISTRIBUTED BY
  297. XFREE SOFTWARE FOUNDATION, INC.) THE PROGRAM, EVEN IF YOU HAVE BEEN
  298. ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY
  299. OTHER PARTY.
  300. X
  301. X
  302. Basically:
  303. X    1. It's Free.
  304. X    2. You can give it away.
  305. X    3. If it bites you,  don't blame us!
  306. X
  307. Patrick Powell
  308. END_OF_FILE
  309. if test 3940 -ne `wc -c <'doc/PLP/LICENSE'`; then
  310.     echo shar: \"'doc/PLP/LICENSE'\" unpacked with wrong size!
  311. fi
  312. # end of 'doc/PLP/LICENSE'
  313. fi
  314. if test -f 'filters/vdmp.c' -a "${1}" != "-c" ; then 
  315.   echo shar: Will not clobber existing file \"'filters/vdmp.c'\"
  316. else
  317. echo shar: Extracting \"'filters/vdmp.c'\" \(4799 characters\)
  318. sed "s/^X//" >'filters/vdmp.c' <<'END_OF_FILE'
  319. X/***************************************************************************
  320. X * U. Minnesota LPD Software * Copyright 1987, 1988, Patrick Powell
  321. X ***************************************************************************
  322. X * MODULE: vdmp.c
  323. X ***************************************************************************
  324. X * Revision History: Created (Well, sort of) Fri Mar  4 19:15:16 CST 1988
  325. X * $Log:    vdmp.c,v $
  326. X * Revision 2.1  88/05/09  10:12:17  papowell
  327. X * *** empty log message ***
  328. X * 
  329. X ***************************************************************************/
  330. X#ifndef lint
  331. static char id_str1[] =
  332. X    "$Header: vdmp.c,v 2.1 88/05/09 10:12:17 papowell Exp $ PLP Copyright 1988 Patrick Powell";
  333. X#endif lint
  334. X/*
  335. X *  reads raster file created by cifplot or plot and dumps it onto the
  336. X *  Varian or Versatec plotter.   Originally derived from the 1984
  337. X *  Berkeley VLSI Tools Distribution.  Has been mangled horribly ever
  338. X *  since.  This code has little redeeming social value.
  339. X *
  340. X *  Note that the number of bits per raster line is given by xwidth.
  341. X *  If vdmp is invoked with -Zr flag, it runs in raw mode, and does not
  342. X *  check for header.
  343. X *  If vdmp is invoked with -Zw flag, it puts out a couple of lines
  344. X *    at end, otherwise a page eject (FF).
  345. X *  It is assumed that BLOCK, the numbers of bytes in the header,
  346. X *  fits in BUFSIZE.
  347. X */
  348. X#include <stdio.h>
  349. X#include <sys/vcmd.h>
  350. X#include <sys/types.h>
  351. X#include <sys/signal.h>
  352. X
  353. X#define IN    0    /* input fcd */
  354. X#define OUT    1    /* output fcd */
  355. X
  356. X#define MAGIC_WORD    0xA5CF4DFA        /* hardwired to the VAX, no doubt */
  357. char magic_string[4] = { 0xFA, 0x4D, 0xCF, 0xA5 };
  358. X
  359. X#define BLOCK        1024
  360. X#define BUFSIZE        BLOCK*128
  361. X
  362. X
  363. int    plotmd[] = { VPLOT };
  364. int    prtmd[]    = { VPRINT };
  365. X
  366. char    buf[BUFSIZE];
  367. int    lines;        /* number of scan lines */
  368. X
  369. int    raw;            /* 1 if -Zr, no check for header */
  370. int    wide;            /* 1 if -Zw, terminate with couple of lines, else FF */
  371. int    nscanbytes;        /* number of bytes per raster line. */
  372. extern int xwidth;        /* width in pixcels */
  373. extern int ylength;        /* number of raster lines per page. */
  374. extern int npages;        /* number of billable pages */
  375. extern int errorcode;        /* 1 = retry, 2 = give up */
  376. extern char *zopts, *index();    /* -Z options to LPR */
  377. X
  378. int    timeout();
  379. X#define    TIMEOUT    (5*60)        /* 5 minutes */
  380. time_t    t, time();
  381. X
  382. filter()
  383. X{
  384. X    int n;
  385. X    char *trailer;
  386. X
  387. X    if( xwidth <= 0 ){
  388. X        fatal( "bad xwidth value %d", xwidth );
  389. X    }
  390. X    if( ylength <= 0 ){
  391. X        fatal( "bad ylength value %d", ylength );
  392. X    }
  393. X    nscanbytes = xwidth / 8;
  394. X    
  395. X    /*
  396. X     * check for -Zrw (raw and wide flag);
  397. X     */
  398. X    if( zopts && index( zopts, 'r' ) ){
  399. X        raw = 1;
  400. X    }
  401. X    if( zopts && index( zopts, 'w' ) ){
  402. X        wide = 1;
  403. X    }
  404. X    /*
  405. X     * check the start of the file for a Magic Word
  406. X     * if there is one, print the string in the header
  407. X     */
  408. X
  409. X    errorcode = 2;    /* no retry */
  410. X
  411. X    if( raw == 0 ){
  412. X        (void)signal(SIGALRM, timeout);
  413. X        if( (n = read(IN, buf, BLOCK)) < 0 ){
  414. X            logerr_die( "read error from file" );
  415. X        }
  416. X
  417. X        errorcode = 1;    /* retry on error */
  418. X
  419. X        if( n==BLOCK && bcmp( buf, magic_string, 4 ) == 0 ){
  420. X            (void) alarm(TIMEOUT);
  421. X            buf[BLOCK] = 0;
  422. X            if( ioctl(OUT, VSETSTATE, prtmd) < 0 ){
  423. X                logerr_die( "ioctl for print mode failed" );
  424. X            }
  425. X            write(OUT, buf+4, strlen(buf+4));
  426. X            if( write(OUT, "\n", 1) != 1 ){
  427. X                logerr_die( "write of header failed" );
  428. X            }
  429. X            (void)alarm(0);
  430. X        } else if( lseek(IN, 0L, 0) ){
  431. X            /* dump file not formatted */
  432. X            logerr_die( "lseek failed" );
  433. X        }
  434. X    }
  435. X
  436. X    errorcode = 1;    /* retry on error */
  437. X    n = putplot();
  438. X    if( lines ){
  439. X        ++npages;
  440. X    }
  441. X
  442. X    /* page feed */
  443. X    (void)alarm(TIMEOUT);
  444. X    if( ioctl(OUT, VSETSTATE, prtmd) < 0 ){
  445. X        logerr_die( "ioctl failed" );
  446. X    }
  447. X    if (wide)
  448. X        trailer = "\n\n\n\n\n";
  449. X    else
  450. X        trailer = "\f";
  451. X    if( write( OUT, trailer, strlen(trailer) ) != strlen(trailer) ){
  452. X        logerr_die( "trailer write failed" );
  453. X    }
  454. X    (void)alarm(0);
  455. X}
  456. X
  457. putplot()
  458. X{
  459. X    int bytes, n;
  460. X
  461. X    bytes = 0;
  462. X    (void)alarm(TIMEOUT);
  463. X    if( ioctl(OUT, VSETSTATE, plotmd) < 0 ){
  464. X        logerr_die( "ioctl to plot mode failed" );
  465. X    }
  466. X    (void)alarm(0);
  467. X    while ((n = read(IN, buf, sizeof(buf))) > 0) {
  468. X        (void)alarm(TIMEOUT);
  469. X        if (write(OUT,buf, n) != n)
  470. X            logerr_die( "write failed" );
  471. X        (void)alarm(0);
  472. X        bytes += n;
  473. X        while( bytes >= nscanbytes ){
  474. X            ++lines;
  475. X            if( lines >= ylength ){
  476. X                ++npages;
  477. X                lines -= ylength;
  478. X            }
  479. X            bytes -= nscanbytes;
  480. X        }
  481. X    }
  482. X    /*
  483. X     * Make sure we send complete raster lines.
  484. X     */
  485. X    if (bytes > 0) {
  486. X        n = nscanbytes - bytes;
  487. X        if (n > 0){
  488. X            bzero(buf, n);
  489. X            (void)alarm(TIMEOUT);
  490. X            if (write(OUT, buf, n) != n)
  491. X                logerr_die( "write failed" );
  492. X            (void)alarm(0);
  493. X            bytes += n;
  494. X        }
  495. X        while( bytes >= nscanbytes ){
  496. X            ++lines;
  497. X            if( lines >= ylength ){
  498. X                ++npages;
  499. X                lines -= ylength;
  500. X            }
  501. X            bytes -= nscanbytes;
  502. X        }
  503. X    }
  504. X}
  505. X
  506. X/*
  507. X *    Die on timeout
  508. X */
  509. timeout()
  510. X    {
  511. X    errorcode = 1;
  512. X    logerr_die( "timeout" );
  513. X    }
  514. X
  515. cleanup() {}    /* dummy for error actions */
  516. END_OF_FILE
  517. if test 4799 -ne `wc -c <'filters/vdmp.c'`; then
  518.     echo shar: \"'filters/vdmp.c'\" unpacked with wrong size!
  519. fi
  520. # end of 'filters/vdmp.c'
  521. fi
  522. if test -f 'man/lpq.1' -a "${1}" != "-c" ; then 
  523.   echo shar: Will not clobber existing file \"'man/lpq.1'\"
  524. else
  525. echo shar: Extracting \"'man/lpq.1'\" \(3795 characters\)
  526. sed "s/^X//" >'man/lpq.1' <<'END_OF_FILE'
  527. X.TH LPQ 1 "19 Mar 1988" "U-MN PLP"
  528. X.ig
  529. X$Header: lpq.1,v 2.2 88/07/01 15:42:26 papowell Exp $
  530. X$Log:    lpq.1,v $
  531. Revision 2.2  88/07/01  15:42:26  papowell
  532. Modified description
  533. X
  534. Revision 2.1  88/05/09  10:08:36  papowell
  535. PLP: Released Version
  536. X
  537. Revision 1.1  88/04/28  10:58:52  papowell
  538. Initial revision
  539. X
  540. X..
  541. X.SH NAME
  542. lpq \- spool queue examination program
  543. X.SH SYNOPSIS
  544. X.B lpq
  545. X[\-Pprinter ]*[\-a][\-l][+[n]][\-D[n]][\-X][ job # ... ][ user ... ]
  546. X.SH DESCRIPTION
  547. X.I lpq
  548. examines the spooling area used by
  549. X.IR lpd (8)
  550. for printing
  551. files on the line printer, and reports the status of the specified jobs or
  552. all jobs associated with a user. 
  553. X.I lpq
  554. invoked without any arguments
  555. reports on the printer given by the default printer
  556. X(see
  557. X.B \-P
  558. option).
  559. XFor each job submitted (i.e. invocation of 
  560. X.IR lpr (1))
  561. X.I lpq
  562. reports the user's name, current rank in the queue, the
  563. names of files comprising the job, the job identifier (a number which
  564. may be supplied to
  565. X.IR lprm (1)
  566. for removing a specific job), and the total size in bytes.
  567. Job ordering is dependent on
  568. the algorithm used to scan the spooling directory and is
  569. XFIFO (First in First Out),
  570. in order of priority level.
  571. XFile names comprising a job may be unavailable
  572. X(when
  573. X.IR lpr (1)
  574. is used as a sink in a pipeline) in which case the file
  575. is indicated as ``(stdin)''.
  576. The following options are available.
  577. X.IP "\fB\-P \fIprinter\fR"
  578. Specifies a particular printer, otherwise the default line printer
  579. is used (or the value of the PRINTER variable in the environment).
  580. If PRINTER is not defined,
  581. then the first entry in the
  582. X.IR /etc/printcap (5)
  583. file is reported.
  584. Multiple printers can be displayed by specifying more than one
  585. X\-P option.
  586. X.IP "\fB\-a\fR"
  587. All printers listed in
  588. X.IR /etc/printcap (5)
  589. file are reported.
  590. X.IP "\fB\-l\fR"
  591. An a\fBl\fRternate display format is used,
  592. which simply reports the user,
  593. jobnumber,
  594. and originating host.
  595. X.IP "[\fB+\fR[\fIn\fR]]"
  596. XForces
  597. X.I lpq
  598. to periodically display the spool queues.
  599. Supplying a number
  600. immediately after the
  601. X.B \+
  602. sign indicates that
  603. X.I lpq
  604. should sleep \fIn\fR seconds in between scans of the queue.
  605. X.IP "\fB\-D\fR[\fIn\fR]"
  606. XEnables display of debugging information.
  607. The 
  608. X.B \-D\fIn\fR
  609. X\fRselects level
  610. X.I n
  611. X(n is a single digit).
  612. X.IP "\fB\-X"
  613. Use an Xperimental version of LPD if the software has been compiled
  614. with the appropriate support;
  615. ignored otherwise.
  616. X.IP "[ job # ... ][ user ... ]"
  617. The options are followed by
  618. a list of user names or job numbers which
  619. are used to select jobs of interest.
  620. X.PP
  621. The
  622. X.I lpq
  623. will report the status of the spool queue (enabled for spooling,
  624. disabled for unspooling),
  625. and the abscense of a server if unspooling is enabled.
  626. The
  627. X.IR lpc (1)
  628. command
  629. X.I "lpc restart <printer>"
  630. may be used to start the server if this is the case.
  631. X.SH FILES
  632. X.nf
  633. X.ta \w'/etc/termcap      'u +.5i +.5i
  634. X/etc/termcap    for manipulating the screen for repeated display
  635. X/etc/printcap    to determine printer characteristics
  636. X/etc/printer_perms    printer permissions
  637. X/usr/spool/*    the spooling directory, as determined from printcap
  638. X/usr/spool/*/cf*    control files specifying jobs
  639. X/usr/spool/*/lock    the lock file to obtain the currently active job 
  640. X.fi
  641. X.SH DIAGNOSTICS
  642. X.br
  643. XExcrutiatingly verbose.
  644. If you are interested in tracing the exact execution,
  645. try setting debug level to 5 (-D5) to see exactly what happens as you run LPQ.
  646. X.SH "SEE ALSO"
  647. lpr(1),
  648. lprm(1),
  649. lpc(1),
  650. lpd(8),
  651. X.br
  652. X.I "PLP - The Public Line Printer Spooler",
  653. by
  654. Patrick Powell,
  655. University of Minnesota.
  656. X.fi
  657. X.SH "HISTORY"
  658. X.PP
  659. The PLP is a reverse engineered version of the Berkeley 4.3BSD Line Printer
  660. Spooler,
  661. done in 1988 at the University of Minnesota.
  662. It has many advanced features which are described in
  663. X.I "PLP - The Public Line Printer Spooler"
  664. by
  665. Patrick Powell,
  666. Department of Computer Science,
  667. University of Minnesota.
  668. END_OF_FILE
  669. if test 3795 -ne `wc -c <'man/lpq.1'`; then
  670.     echo shar: \"'man/lpq.1'\" unpacked with wrong size!
  671. fi
  672. # end of 'man/lpq.1'
  673. fi
  674. if test -f 'man/lprm.1' -a "${1}" != "-c" ; then 
  675.   echo shar: Will not clobber existing file \"'man/lprm.1'\"
  676. else
  677. echo shar: Extracting \"'man/lprm.1'\" \(3449 characters\)
  678. sed "s/^X//" >'man/lprm.1' <<'END_OF_FILE'
  679. X.TH LPRM 1 "19 Mar 1988" "U-MN PLP"
  680. X.ig
  681. X$Header: lprm.1,v 2.1 88/05/09 10:08:45 papowell Exp $
  682. X$Log:    lprm.1,v $
  683. Revision 2.1  88/05/09  10:08:45  papowell
  684. PLP: Released Version
  685. X
  686. Revision 1.1  88/04/28  10:58:55  papowell
  687. Initial revision
  688. X
  689. X..
  690. X.SH NAME
  691. lprm \- remove jobs from the line printer spooling queue
  692. X.SH SYNOPSIS
  693. X.B lprm
  694. X[
  695. X.BI \-P printer
  696. X] [
  697. X.B \-
  698. X] [
  699. X.BI \-D n
  700. X] [
  701. X.B \-X
  702. X] [
  703. job # ...
  704. X] [
  705. user ...
  706. X]
  707. X.SH DESCRIPTION
  708. X.I Lprm
  709. will remove jobs
  710. from a spool queue.
  711. Since the spooling directory and files in it are
  712. owned by 
  713. X.I daemon,
  714. using
  715. X.I lprm
  716. is normally the only method by which a user may remove a job.
  717. X.PP
  718. The use must specify the job to be removed by providing a job
  719. number or user name.
  720. Ordinary users may remove jobs which are submitted by themselves;
  721. users with
  722. X.I Control
  723. permissions in the 
  724. X.I printer_perms
  725. file may remove other users jobs.
  726. Root can remove jobs on the local host and jobs submitted from the
  727. local host.
  728. X.PP
  729. If the
  730. X.B \-
  731. flag is specified, 
  732. X.I lprm
  733. will remove all jobs which a user owns.
  734. If a user with
  735. X.I control
  736. permissions uses this flag,
  737. the spool queue will be emptied entirely.
  738. The submitter of a job is determined by the information returned by
  739. X.IR getpwent (3)
  740. for the real userid of the process,
  741. and the host name by the information returned by
  742. X.IR gethostent (3).
  743. X.PP
  744. Specifying a user's name or list of user names will cause
  745. X.I lprm
  746. to attempt to remove any jobs queued belonging to that user
  747. X(or users). 
  748. This form of invoking
  749. X.I lprm
  750. is useful only to the super-user or users with
  751. X.I control
  752. permissions.
  753. X.PP
  754. A user may dequeue an individual job by specifying its job number.
  755. This number may be obtained by using
  756. X.IR lpq (1).
  757. X.I Lprm
  758. will announce the names of any files it removes and is silent if
  759. there are no jobs in the queue which match the request list.
  760. X.PP
  761. If necessary,
  762. X.I lprm
  763. will kill off an active spool queue server
  764. which is processing a job to be removed.
  765. After jobs have been removed,
  766. the server will be restarted.
  767. X.IP \fB\-P\fP\ printer
  768. The
  769. X.B \-P
  770. option specifies the spooling queue.
  771. If it is not provided,
  772. the default printer is the
  773. the value of the PRINTER environment variable and then the
  774. first printer in the
  775. X.I printcap
  776. database.
  777. X.IP \fB\-D\fR[\fIn\fR]
  778. The
  779. X.B \-D\fIn\fR
  780. X\fRselects debugging level
  781. X.I n
  782. X(n is a single digit).
  783. This may be used to produce a trace of the actions of
  784. X.IR lprm .
  785. X.IP \fB\-X\fR
  786. The \fB\-X
  787. option uses an Xperimental version of lpd if the software has been compiled
  788. with the appropriate support;
  789. ignored otherwise.
  790. X.SH FILES
  791. X.nf
  792. X.ta \w'/usr/spool/*/lock   'u
  793. X/etc/printcap    printer characteristics file
  794. X/etc/printer_perms    printer permissions
  795. X/usr/spool/*    spooling directories
  796. X/usr/spool/*/lock    lock file used to obtain the pid of the current
  797. X    daemon and the job number of the currently active job
  798. X.fi
  799. X.SH BUGS
  800. Since there are race conditions possible in the update of the lock file,
  801. the currently active job may be incorrectly identified;
  802. thus the need to specify the job number to be removed.
  803. X.SH "SEE ALSO"
  804. lpr(1),
  805. lpq(1),
  806. lpd(8)
  807. X.br
  808. X.I "PLP - The Public Line Printer Spooler",
  809. by
  810. Patrick Powell,
  811. University of Minnesota.
  812. X.fi
  813. X.SH "HISTORY"
  814. X.PP
  815. The PLP is a reverse engineered version of the Berkeley 4.3BSD Line Printer
  816. Spooler,
  817. done in 1988 at the University of Minnesota.
  818. It has many advanced features which are described in
  819. X.I "PLP - The Public Line Printer Spooler"
  820. by
  821. Patrick Powell,
  822. Department of Computer Science,
  823. University of Minnesota.
  824. END_OF_FILE
  825. if test 3449 -ne `wc -c <'man/lprm.1'`; then
  826.     echo shar: \"'man/lprm.1'\" unpacked with wrong size!
  827. fi
  828. # end of 'man/lprm.1'
  829. fi
  830. if test -f 'src/errormsg.c' -a "${1}" != "-c" ; then 
  831.   echo shar: Will not clobber existing file \"'src/errormsg.c'\"
  832. else
  833. echo shar: Extracting \"'src/errormsg.c'\" \(5344 characters\)
  834. sed "s/^X//" >'src/errormsg.c' <<'END_OF_FILE'
  835. X/***************************************************************************
  836. X * U. Minnesota LPD Software * Copyright 1987, 1988, Patrick Powell
  837. X ***************************************************************************
  838. X * MODULE: Errormsg.c
  839. X * error messages and logging
  840. X * log:
  841. X *  --message on stderr and on stdout if "Echo_on_stdout" is set
  842. X *  --if the severity is high enough, will also log using syslog().
  843. X *  --saves the last "non-Debug" log message
  844. X * logerr:
  845. X *  --formats the error message corresponding to "errno" and calls log();
  846. X * fatal:
  847. X *  -- log() and exit() with Errorcode
  848. X * logerr_die:
  849. X *  -- logerr() and exit() with Errorcode
  850. X ***************************************************************************
  851. X * Revision History: Created Sun Jan  3 18:41:01 CST 1988
  852. X * $Log:    errormsg.c,v $
  853. X * Revision 3.1  88/06/18  09:34:09  papowell
  854. X * Version 3.0- Distributed Sat Jun 18 1988
  855. X * 
  856. X * Revision 2.1  88/05/09  10:08:01  papowell
  857. X * PLP: Released Version
  858. X * 
  859. X * Revision 1.4  88/04/26  15:46:11  papowell
  860. X * Added a datestamp to all messages
  861. X * 
  862. X * Revision 1.3  88/04/06  12:12:43  papowell
  863. X * Minor updates, changes in error message formats.
  864. X * Elimination of the AF_UNIX connections, use AF_INET only.
  865. X * Better error messages.
  866. X * 
  867. X * Revision 1.2  88/03/25  14:59:24  papowell
  868. X * Debugged Version:
  869. X * 1. Added the PLP control file first transfer
  870. X * 2. Checks for MX during file transfers
  871. X * 3. Found and fixed a mysterious bug involving the SYSLOG facilities;
  872. X *     apparently they open files and then assume that they will stay
  873. X *     open.
  874. X * 4. Made sure that stdin, stdout, stderr was available at all times.
  875. X * 
  876. X * Revision 1.1  88/03/01  11:08:23  papowell
  877. X * Initial revision
  878. X * 
  879. X ***************************************************************************/
  880. X#ifndef lint
  881. static char id_str1[] =
  882. X    "$Header: errormsg.c,v 3.1 88/06/18 09:34:09 papowell Exp $ PLP Copyright 1988 Patrick Powell";
  883. X#endif lint
  884. X
  885. X#include "lp.h"
  886. X
  887. X/*
  888. X * Errormsg( err ) returns a printable form of the errormessage
  889. X * corresponding to errno.
  890. X */
  891. X
  892. char *
  893. XErrormsg( err )
  894. X    int err;
  895. X{
  896. X    char *cp;
  897. X    static char msgbuf[30];
  898. X
  899. X    if( err >= 0 && err <= sys_nerr ){
  900. X        cp = sys_errlist[err];
  901. X    } else {
  902. X        (void)sprintf(msgbuf,"errno=%d",err);
  903. X        cp = msgbuf;
  904. X    }
  905. X    return(cp);
  906. X}
  907. X
  908. struct msgkind {
  909. X    int *var;
  910. X    char *str;
  911. X};
  912. static struct msgkind msg_name[] = {
  913. X    { &XLOG_ERR, "LOG_ERR" },
  914. X    { &XLOG_CRIT, "LOG_CRIT" },
  915. X    { &XLOG_WARNING, "LOG_WARNING" },
  916. X    { &XLOG_NOTICE, "LOG_NOTICE" },
  917. X    { &XLOG_INFO, "LOG_INFO" },
  918. X    { &XLOG_DEBUG, "LOG_DEBUG" },
  919. X    { 0 }
  920. X};
  921. X
  922. static
  923. char *
  924. logmsg( kind )
  925. X    int kind;
  926. X{
  927. X    int i;
  928. X    static char b[35];
  929. X
  930. X    for( i = 0; msg_name[i].var; ++i ){
  931. X        if( *msg_name[i].var == kind ){
  932. X            return( msg_name[i].str );
  933. X        }
  934. X    }
  935. X    (void)sprintf(b, "bad message type %d",  kind );
  936. X    return(b);
  937. X}
  938. X
  939. X/*
  940. X * log( int severity; char *msg; args )
  941. X *      1. format the message; msg and args are similar to printf
  942. X *        2. output on stderr
  943. X *        3. if "Echo_on_stdout" output on stdout
  944. X *        4. if severity high enough,  log using syslog()
  945. X *        5. if not a Debug message, save in Last_errormsg[]
  946. X */
  947. X/*VARARGS2*/
  948. log(kind, msg, a1, a2, a3, a4, a5, a6, a7, a8, a9)
  949. X    char *msg, *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8, *a9;
  950. X{
  951. X    char buf[BUFSIZ];
  952. X    int omask;
  953. X
  954. X    omask = sigblock(sigmask(SIGCHLD)|sigmask(SIGHUP)
  955. X        |sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGTERM));
  956. X    buf[0] = 0;
  957. X    if(Name && *Name){
  958. X        (void)sprintf(buf+strlen(buf),"%s: ", Name);
  959. X    }
  960. X    if(Printer && *Printer){
  961. X        (void)sprintf(buf+strlen(buf),"%s- ", Printer);
  962. X    }
  963. X    if(Debug){
  964. X        (void)sprintf(buf+strlen(buf),"pid=%d, %s, ",getpid(),logmsg(kind));
  965. X    }
  966. X    (void)sprintf(buf+strlen(buf), msg, a1, a2, a3, a4, a5, a6, a7, a8, a9);
  967. X    (void)sprintf(buf+strlen(buf)," at %s",Time_str() );
  968. X
  969. X    if(Echo_on_stdout){
  970. X        (void)fprintf(stdout,"%s\n", buf);
  971. X        (void)fflush(stdout);
  972. X    }
  973. X    (void)fprintf(stderr,"%s\n", buf);
  974. X    (void)fflush(stderr);
  975. X    if( kind <= XLOG_INFO ){
  976. X        use_syslog( kind, buf);
  977. X    }
  978. X    if( kind != XLOG_DEBUG ){
  979. X        (void)strcpy( Last_errormsg, buf );
  980. X    }
  981. X    (void)sigsetmask(omask);
  982. X}
  983. X
  984. X/*VARARGS2*/
  985. fatal(kind, msg, a1, a2, a3, a4, a5, a6, a7, a8, a9)
  986. X    char *msg, *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8, *a9;
  987. X{
  988. X    log( kind, msg, a1, a2, a3, a4, a5, a6, a7, a8, a9);
  989. X    cleanup();
  990. X    exit(Errorcode);
  991. X}
  992. X
  993. X/*VARARGS2*/
  994. logerr( kind,msg, a1, a2, a3, a4, a5, a6, a7, a8, a9)
  995. X    char *msg, *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8, *a9;
  996. X{
  997. X    int err = errno;
  998. X    char buf1[BUFSIZ];
  999. X
  1000. X    (void)sprintf(buf1, msg, a1, a2, a3, a4, a5, a6, a7, a8, a9);
  1001. X    log( kind,"%s - %s", buf1, Errormsg(err) );
  1002. X    errno = err;
  1003. X}
  1004. X
  1005. X/*VARARGS2*/
  1006. logerr_die( kind,msg, a1, a2, a3, a4, a5, a6, a7, a8, a9)
  1007. X    char *msg, *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8, *a9;
  1008. X{
  1009. X    logerr( kind,msg, a1, a2, a3, a4, a5, a6, a7, a8, a9);
  1010. X    cleanup();
  1011. X    exit(Errorcode);
  1012. X}
  1013. X
  1014. X/*
  1015. X * use the syslog(8) deamon to do our logging
  1016. X */
  1017. X#ifdef NOSYSLOG
  1018. static FILE *f;
  1019. X#else NOSYSLOG
  1020. X#include <syslog.h>
  1021. X#endif NOSYSLOG
  1022. static int init;
  1023. X
  1024. use_syslog( kind, msg )
  1025. X    int kind;
  1026. X    char * msg;
  1027. X{
  1028. X    if(Debug>7){
  1029. X        (void)fprintf(stderr, "syslog: %s\n", msg );
  1030. X        (void)fflush(stderr);
  1031. X    }
  1032. X#ifdef NOSYSLOG
  1033. X    if( f != NULL || (f = fopen( "/dev/console", "w" ) ) != NULL ){
  1034. X        (void)fprintf( f, "syslog: LPD %s\n", msg );
  1035. X        (void)fflush(f);
  1036. X    }
  1037. X#else NOSYSLOG
  1038. X    if(init == 0 ){
  1039. X        init = 1;
  1040. X    }
  1041. X#    ifdef IS_SUN
  1042. X        (void)syslog(kind, "%s", msg);
  1043. X#    endif
  1044. X#    ifdef IS_VAX
  1045. X        (void)syslog(LOG_LPR|kind, msg);
  1046. X#    endif
  1047. X#endif NOSYSLOG
  1048. X}
  1049. END_OF_FILE
  1050. if test 5344 -ne `wc -c <'src/errormsg.c'`; then
  1051.     echo shar: \"'src/errormsg.c'\" unpacked with wrong size!
  1052. fi
  1053. # end of 'src/errormsg.c'
  1054. fi
  1055. if test -f 'src/lprm.c' -a "${1}" != "-c" ; then 
  1056.   echo shar: Will not clobber existing file \"'src/lprm.c'\"
  1057. else
  1058. echo shar: Extracting \"'src/lprm.c'\" \(5292 characters\)
  1059. sed "s/^X//" >'src/lprm.c' <<'END_OF_FILE'
  1060. X/***************************************************************************
  1061. X * U. Minnesota LPD Software * Copyright 1987, 1988, Patrick Powell
  1062. X ***************************************************************************
  1063. X * MODULE: lprm.c
  1064. X * lprm- remove files
  1065. X ***************************************************************************
  1066. X * Revision History: Created Mon Jan 25 14:04:26 CST 1988
  1067. X * $Log:    lprm.c,v $
  1068. X * Revision 3.1  88/06/18  09:35:07  papowell
  1069. X * Version 3.0- Distributed Sat Jun 18 1988
  1070. X * 
  1071. X * Revision 2.2  88/05/14  10:20:53  papowell
  1072. X * Modified -X flag handling
  1073. X * 
  1074. X * Revision 2.1  88/05/09  10:09:32  papowell
  1075. X * PLP: Released Version
  1076. X * 
  1077. X * Revision 1.6  88/04/27  18:02:41  papowell
  1078. X * The SIGCHLD signal has an odd behaviour on some systems.  Modified so that
  1079. X * it will not get set UNLESS processes are started;  also,  it is reset
  1080. X * to SIG_DFL, not SIG_IGN.
  1081. X * 
  1082. X * Revision 1.5  88/04/15  13:06:06  papowell
  1083. X * Std_environ() call added, to ensure that fd 0 (stdin), 1 (stdout), 2(stderr)
  1084. X * have valid file descriptors;  if not open, then /dev/null is used.
  1085. X * 
  1086. X * Revision 1.4  88/04/06  12:12:39  papowell
  1087. X * Minor updates, changes in error message formats.
  1088. X * Elimination of the AF_UNIX connections, use AF_INET only.
  1089. X * Better error messages.
  1090. X * 
  1091. X * Revision 1.3  88/03/25  15:00:48  papowell
  1092. X * Debugged Version:
  1093. X * 1. Added the PLP control file first transfer
  1094. X * 2. Checks for MX during file transfers
  1095. X * 3. Found and fixed a mysterious bug involving the SYSLOG facilities;
  1096. X *     apparently they open files and then assume that they will stay
  1097. X *     open.
  1098. X * 4. Made sure that stdin, stdout, stderr was available at all times.
  1099. X * 
  1100. X * Revision 1.2  88/03/11  19:27:59  papowell
  1101. X * Minor Changes, Updates
  1102. X * 
  1103. X * Revision 1.1  88/03/01  11:08:55  papowell
  1104. X * Initial revision
  1105. X * 
  1106. X ***************************************************************************/
  1107. X#ifndef lint
  1108. static char id_str1[] =
  1109. X    "$Header: lprm.c,v 3.1 88/06/18 09:35:07 papowell Exp $ PLP Copyright 1988 Patrick Powell";
  1110. X#endif lint
  1111. X#include "lp.h"
  1112. X
  1113. extern int cleanup();
  1114. X
  1115. main(argc, argv)
  1116. X    int argc;
  1117. X    char **argv;
  1118. X{
  1119. X    struct passwd *pw_ent;        /* user entry in /etc/passwd */
  1120. X
  1121. X    /*
  1122. X     * set umask to avoid problems with user umask
  1123. X     */
  1124. X    (void)umask(0);
  1125. X    /*
  1126. X     * Set fd 0, 1, 2 to /dev/null if not open
  1127. X     */
  1128. X    Std_environ();
  1129. X#    ifdef XPERIMENT
  1130. X        Setup_test();
  1131. X#    endif XPERIMENT
  1132. X    /*
  1133. X     * set up the pathnames for information files
  1134. X     */
  1135. X    Tailor_names();
  1136. X    /*
  1137. X     * set up the From information
  1138. X     */
  1139. X    From = Host;
  1140. X    /*
  1141. X     * get the user information
  1142. X     */
  1143. X    if( (pw_ent = getpwuid( getuid() )) == 0 ){
  1144. X        logerr_die( XLOG_INFO, "getpwuid failed on uid %d", getuid());
  1145. X    }
  1146. X    (void)strcpy( LOGNAME, pw_ent->pw_name );
  1147. X    Person = LOGNAME;
  1148. X    if( getuid() == 0 ){
  1149. X        /* we are being invoked by root */
  1150. X        Is_root = 1;
  1151. X    }
  1152. X    /*
  1153. X     * setup parameters
  1154. X     */
  1155. X    Lprm_parms(argc, argv);
  1156. X    /*
  1157. X     * set signals
  1158. X     */
  1159. X    (void)signal(SIGPIPE, SIG_IGN);
  1160. X    (void)signal(SIGHUP, cleanup);
  1161. X    (void)signal(SIGINT, cleanup);
  1162. X    (void)signal(SIGQUIT, cleanup);
  1163. X    (void)signal(SIGTERM, cleanup);
  1164. X    if( Parmcount != 0 ){
  1165. X        rmjob();
  1166. X    }
  1167. X    exit( 0 );
  1168. X}
  1169. X
  1170. X/***************************************************************************
  1171. X * cleanup()
  1172. X * remove the temp files
  1173. X ***************************************************************************/
  1174. X
  1175. cleanup()
  1176. X{
  1177. X    exit( 1 );
  1178. X}
  1179. X
  1180. X/***************************************************************************
  1181. X * Lprm_parms( int arc, char **argv )
  1182. X * 1. pick off the options
  1183. X * 2. set up the parameters
  1184. X ***************************************************************************/
  1185. X
  1186. static char *optstr = "P:D:Xa";
  1187. static int Xpert;
  1188. static int all_flag;
  1189. Lprm_parms( argc, argv )
  1190. X    int argc;
  1191. X    char **argv;
  1192. X{
  1193. X    int option;
  1194. X    char *s;
  1195. X    int i;
  1196. X
  1197. X    while( (option = Getopt(argc,argv,optstr)) != EOF ){
  1198. X        switch( option ){
  1199. X        case 'D':
  1200. X            if(Debug){
  1201. X                Diemsg("Duplicate -D option");
  1202. X            }
  1203. X            if( sscanf( Optarg, "%d", &Debug ) != 1 || Debug <= 0){
  1204. X                Diemsg("-D parameter is not positive integer" );
  1205. X            }
  1206. X            break;
  1207. X        case 'X':
  1208. X            if( Xpert ){
  1209. X                Diemsg("Duplicate -X option");
  1210. X            }
  1211. X#            ifdef DEBUG
  1212. X                Setup_test();
  1213. X                Tailor_names();
  1214. X#            else
  1215. X                Diemsg( "-X not allowed" );
  1216. X#            endif DEBUG
  1217. X            break;
  1218. X        case 'P':
  1219. X            if( Printer ){
  1220. X                Diemsg("Duplicate -P option");
  1221. X            }
  1222. X            Printer = Optarg;
  1223. X            break;
  1224. X        case 'a':
  1225. X            if( all_flag ){
  1226. X                Diemsg("Duplicate -a option");
  1227. X            }
  1228. X            all_flag = 1;
  1229. X            break;
  1230. X        case '?':
  1231. X            break;
  1232. X        default:
  1233. X            fatal(XLOG_INFO, "Lprm_parms: badparm %c", option );
  1234. X        }
  1235. X    }
  1236. X
  1237. X    /*
  1238. X     * set up the Parms[] array
  1239. X     */
  1240. X    for( ; Optind < argc; ++Optind ){
  1241. X        if( Parmcount < MAXPARMS ){
  1242. X            s = argv[Optind];
  1243. X            Parms[Parmcount].str = s;
  1244. X            if( isdigit( *s )){
  1245. X                Parms[Parmcount].num = atoi(s);
  1246. X            } else {
  1247. X                Parms[Parmcount].num = -1;
  1248. X            }
  1249. X            ++Parmcount;
  1250. X        } else {
  1251. X            Diemsg( "too many files to print; break job up" );
  1252. X        }
  1253. X    }
  1254. X    /*
  1255. X     * get the default printer
  1256. X     */
  1257. X    Get_Printer(0);
  1258. X    /*
  1259. X     * check for the all option
  1260. X     */
  1261. X    if( all_flag ){
  1262. X        if( Parmcount > 0 ){
  1263. X            Diemsg("-a cannot be combined with other options" );
  1264. X        }
  1265. X        Parms[0].str = "-all";
  1266. X        Parmcount = 1;
  1267. X    }
  1268. X    if(Debug>4){
  1269. X        (void)fprintf(stdout,"Printer %s, Parmcount %d ", Printer, Parmcount );
  1270. X        for( i = 0; i < Parmcount; ++i )
  1271. X            (void)fprintf(stdout," '%s'(%d)",Parms[i].str, Parms[i].num ); 
  1272. X        (void)fprintf(stdout,"\n"); (void)fflush(stdout);
  1273. X    }
  1274. X}
  1275. END_OF_FILE
  1276. if test 5292 -ne `wc -c <'src/lprm.c'`; then
  1277.     echo shar: \"'src/lprm.c'\" unpacked with wrong size!
  1278. fi
  1279. # end of 'src/lprm.c'
  1280. fi
  1281. if test -f 'src/remote_ops.c' -a "${1}" != "-c" ; then 
  1282.   echo shar: Will not clobber existing file \"'src/remote_ops.c'\"
  1283. else
  1284. echo shar: Extracting \"'src/remote_ops.c'\" \(5087 characters\)
  1285. sed "s/^X//" >'src/remote_ops.c' <<'END_OF_FILE'
  1286. X/***************************************************************************
  1287. X * U. Minnesota LPD Software * Copyright 1987, 1988, Patrick Powell
  1288. X ***************************************************************************
  1289. X * MODULE: Remote_ops.c
  1290. X * intiate remote operations from the local machine
  1291. X ***************************************************************************
  1292. X * Revision History: Created Sun Jan 17 19:55:38 CST 1988
  1293. X * $Log:    remote_ops.c,v $
  1294. X * Revision 3.3  88/07/06  17:32:41  papowell
  1295. X * Added retry for status connection.  Sigh.
  1296. X * 
  1297. X * Revision 3.2  88/06/24  17:55:38  papowell
  1298. X * MODS for VAX 4.3BSD UNIX
  1299. X * 
  1300. X * Revision 3.1  88/06/18  09:35:29  papowell
  1301. X * Version 3.0- Distributed Sat Jun 18 1988
  1302. X * 
  1303. X * Revision 2.1  88/05/09  10:10:01  papowell
  1304. X * PLP: Released Version
  1305. X * 
  1306. X * Revision 1.4  88/04/06  12:12:58  papowell
  1307. X * Minor updates, changes in error message formats.
  1308. X * Elimination of the AF_UNIX connections, use AF_INET only.
  1309. X * Better error messages.
  1310. X * 
  1311. X * Revision 1.3  88/03/25  15:01:23  papowell
  1312. X * Debugged Version:
  1313. X * 1. Added the PLP control file first transfer
  1314. X * 2. Checks for MX during file transfers
  1315. X * 3. Found and fixed a mysterious bug involving the SYSLOG facilities;
  1316. X *     apparently they open files and then assume that they will stay
  1317. X *     open.
  1318. X * 4. Made sure that stdin, stdout, stderr was available at all times.
  1319. X * 
  1320. X * Revision 1.2  88/03/11  19:27:55  papowell
  1321. X * Minor Changes, Updates
  1322. X * 
  1323. X * Revision 1.1  88/03/01  11:09:08  papowell
  1324. X * Initial revision
  1325. X * 
  1326. X ***************************************************************************/
  1327. X#ifndef lint
  1328. static char id_str1[] =
  1329. X    "$Header: remote_ops.c,v 3.3 88/07/06 17:32:41 papowell Locked $ PLP Copyright 1988 Patrick Powell";
  1330. X#endif lint
  1331. X
  1332. X#include "lp.h"
  1333. X
  1334. X/***************************************************************************
  1335. X * Remote_status()
  1336. X * get the status from the remote Host RM for Printer RP
  1337. X ***************************************************************************/
  1338. Remote_status()
  1339. X{
  1340. X    char buf[BUFSIZ];
  1341. X
  1342. X    if( RP == 0 || *RP == 0 ){
  1343. X        fatal(XLOG_INFO, "no RP specified for RM (%s)", RM );
  1344. X    }
  1345. X    (void)sprintf( buf, "%c%s\n",  Short_format? REQ_DSHORT : REQ_DLONG,RP);
  1346. X    if(Debug>3)log(XLOG_DEBUG,"Remote_status: %s, '%d'%s",RM,buf[0],buf+1);
  1347. X    if( JSUCC == Link_line( 3, buf )){
  1348. X        if(Debug>4)log(XLOG_DEBUG,"request sent");
  1349. X        Link_get();
  1350. X    } else {
  1351. X        (void)fprintf( stdout, "Remote connect to '%s' (%s) failed: %s\n",
  1352. X            RP, RM, Errormsg(errno));
  1353. X    }
  1354. X    Link_close();
  1355. X}
  1356. X
  1357. X/***************************************************************************
  1358. X * Remote_remove()
  1359. X * send a remote remove request to the remote Host
  1360. X ***************************************************************************/
  1361. Remote_remove( )
  1362. X{
  1363. X    char buf[BUFSIZ];        /* holds command */
  1364. X    char *bp, *ep;            /* ACME Pointers, Inc. */
  1365. X    int i;                    /* ACME Integers, Inc. */
  1366. X    static char *xsp = " ";    /* needs a space */
  1367. X
  1368. X    /*
  1369. X     * set up the remote command format:
  1370. X     * <REQ_REMOVE>Printer Person [Parms]
  1371. X     */
  1372. X    bp = buf; ep = buf+sizeof(buf);
  1373. X    *bp++ = REQ_REMOVE;
  1374. X    if( RP == 0 || *RP == 0 ){
  1375. X        fatal( XLOG_INFO, "no RP specified for RM %s", RM );
  1376. X    }
  1377. X    bp = estrcp( bp, RP, ep );
  1378. X    bp = estrcp( bp, xsp, ep );
  1379. X    bp = estrcp( bp, Person, ep );
  1380. X    for( i = 0; i < Parmcount; ++i ){
  1381. X        bp = estrcp( bp, xsp, ep );
  1382. X        bp = estrcp( bp, Parms[i].str, ep );
  1383. X    }
  1384. X    bp = estrcp( bp, "\n", ep );
  1385. X    /*
  1386. X     * check command line for length
  1387. X     */
  1388. X    if( bp == 0 ){
  1389. X        fatal( XLOG_INFO, "Remote_remove: command line too long '%s'");
  1390. X    }
  1391. X    /*
  1392. X     * send command
  1393. X     */
  1394. X    if(Debug>3)log(XLOG_DEBUG,"Remote_remove: %s, '%d'%s",RM,buf[0],buf+1);
  1395. X    if( JSUCC == Link_line( 3, buf )){
  1396. X        if(Debug>3)log(XLOG_DEBUG,"request sent");
  1397. X        Link_get();
  1398. X    }
  1399. X    Link_close();
  1400. X}
  1401. X
  1402. X/***************************************************************************
  1403. X * Remote_control(cmd)
  1404. X * send the remote command to the printer
  1405. X * This has the form: \006person command RP
  1406. X ***************************************************************************/
  1407. Remote_control(cmd)
  1408. X    char *cmd;
  1409. X{
  1410. X    char buf[BUFSIZ];
  1411. X
  1412. X    if( RP == 0 || *RP == 0 ){
  1413. X        fatal(XLOG_INFO, "no RP specified for RM (%s)", RM );
  1414. X    }
  1415. X    (void)sprintf( buf, "%c%s %s %s\n",  REQ_CONTROL,Person,cmd,RP);
  1416. X    if(Debug>3)log(XLOG_DEBUG,"Remote_control:%s '%d%'%s'",RM,buf[0],buf+1);
  1417. X    if( JSUCC == Link_line( 3, buf )){
  1418. X        if(Debug>4)log(XLOG_DEBUG,"request sent");
  1419. X        Link_get();
  1420. X    } else {
  1421. X        (void)fprintf( stdout, "Remote connect to '%s' (%s) failed: %s\n",
  1422. X            RP, RM, Errormsg(errno));
  1423. X    }
  1424. X    Link_close();
  1425. X}
  1426. X
  1427. X/***************************************************************************
  1428. X * Remote_start()
  1429. X * start the remote printer
  1430. X ***************************************************************************/
  1431. Remote_start()
  1432. X{
  1433. X    char buf[BUFSIZ];
  1434. X    int succ;
  1435. X
  1436. X    if( RP == 0 || *RP == 0 ){
  1437. X        fatal(XLOG_INFO, "no RP specified for RM (%s)", RM );
  1438. X    }
  1439. X    (void)sprintf( buf, "%c%s\n", REQ_START, RP);
  1440. X    if(Debug>3)log(XLOG_DEBUG,"Remote_start:%s '%d%'%s'",RM,buf[0],buf+1);
  1441. X    succ = Link_line( 3, buf );
  1442. X    if( JSUCC == succ){
  1443. X        if(Debug>4)log(XLOG_DEBUG,"request sent");
  1444. X        (void)Link_confirm();
  1445. X    }
  1446. X    Link_close();
  1447. X    return( JSUCC == succ );
  1448. X}
  1449. END_OF_FILE
  1450. if test 5087 -ne `wc -c <'src/remote_ops.c'`; then
  1451.     echo shar: \"'src/remote_ops.c'\" unpacked with wrong size!
  1452. fi
  1453. # end of 'src/remote_ops.c'
  1454. fi
  1455. if test -f 'src/sendmail.c' -a "${1}" != "-c" ; then 
  1456.   echo shar: Will not clobber existing file \"'src/sendmail.c'\"
  1457. else
  1458. echo shar: Extracting \"'src/sendmail.c'\" \(3436 characters\)
  1459. sed "s/^X//" >'src/sendmail.c' <<'END_OF_FILE'
  1460. X/***************************************************************************
  1461. X * U. Minnesota LPD Software * Copyright 1987, 1988, Patrick Powell
  1462. X ***************************************************************************
  1463. X * MODULE: sendmail.c
  1464. X * send mail to user on completion of a job
  1465. X ***************************************************************************
  1466. X * Revision History: Created Fri Jan 15 15:17:10 CST 1988
  1467. X * $Log:    sendmail.c,v $
  1468. X * Revision 3.1  88/06/18  09:35:36  papowell
  1469. X * Version 3.0- Distributed Sat Jun 18 1988
  1470. X * 
  1471. X * Revision 2.1  88/05/09  10:10:13  papowell
  1472. X * PLP: Released Version
  1473. X * 
  1474. X * Revision 1.3  88/04/06  12:13:55  papowell
  1475. X * Minor updates, changes in error message formats.
  1476. X * Elimination of the AF_UNIX connections, use AF_INET only.
  1477. X * Better error messages.
  1478. X * 
  1479. X * Revision 1.2  88/03/25  15:01:36  papowell
  1480. X * Debugged Version:
  1481. X * 1. Added the PLP control file first transfer
  1482. X * 2. Checks for MX during file transfers
  1483. X * 3. Found and fixed a mysterious bug involving the SYSLOG facilities;
  1484. X *     apparently they open files and then assume that they will stay
  1485. X *     open.
  1486. X * 4. Made sure that stdin, stdout, stderr was available at all times.
  1487. X * 
  1488. X * Revision 1.1  88/03/01  11:09:14  papowell
  1489. X * Initial revision
  1490. X * 
  1491. X ***************************************************************************/
  1492. X#ifndef lint
  1493. static char id_str1[] =
  1494. X    "$Header: sendmail.c,v 3.1 88/06/18 09:35:36 papowell Exp $ PLP Copyright 1988 Patrick Powell";
  1495. X#endif lint
  1496. X
  1497. X#include "lp.h"
  1498. X
  1499. X/*
  1500. X * sendmail ---
  1501. X *   tell people about job completion
  1502. X * 1. fork a sendmail process
  1503. X * 2. if successful, send the good news
  1504. X * 3. if unsuccessful, send the bad news
  1505. X */
  1506. sendmail(q, status)
  1507. X    struct queue *q;
  1508. X    int status;
  1509. X{
  1510. X    static int p[2];    /* pipe */
  1511. X    int i;                /* ACME Integer, Inc. */
  1512. X    char buf[100];
  1513. X    FILE *mail;            /* mail file */
  1514. X    int pid;            /* sendmail process */
  1515. X    union wait stat;    /* daughter status */
  1516. X
  1517. X    (void)sprintf(buf, "%s %s", MAIL, MAILNAME );
  1518. X    if(Debug>3)log( XLOG_DEBUG, "mail command: %s", buf );
  1519. X    if( pipe(p) < 0 ){
  1520. X        logerr_die( XLOG_NOTICE, "pipe failed for sendmail" );
  1521. X    }
  1522. X    /*
  1523. X     * start up sendmail process
  1524. X     */
  1525. X    if((pid = fork()) == 0){
  1526. X        if( p[0] ){
  1527. X            if( dup2(p[0], 0) < 0 ){
  1528. X                logerr_die( XLOG_NOTICE, "dup2 failed in sendmail child" );
  1529. X            }
  1530. X            (void)close(p[0]);
  1531. X        }
  1532. X        (void)close(p[1]);
  1533. X        mexecv(buf);
  1534. X        logerr_die(XLOG_INFO, "exec mail failed: %s", buf);
  1535. X    } else if(pid < 0) {                /* parent */
  1536. X        logerr_die( XLOG_NOTICE, "sendmail: fork failed" );
  1537. X    }
  1538. X    (void)close(p[0]);
  1539. X    if( (mail = fdopen(p[1], "w")) == NULL ){
  1540. X        logerr_die( XLOG_NOTICE, "sendmail: fdopen failed" );
  1541. X    }
  1542. X    (void)fprintf(mail,"To: %s@%s\n", q->q_user, &q->q_from);
  1543. X    (void)fprintf(mail,"Subject: %s printer job\n\n", Printer);
  1544. X    (void)fprintf(mail,"Your %s printer job %d (%s)",Printer,
  1545. X        q->q_num, q->q_data);
  1546. X    switch(  status ){
  1547. X        case JSUCC:
  1548. X            (void)fprintf( mail, " was successful.\n" );
  1549. X            break;
  1550. X        case JFAIL:
  1551. X            (void)fprintf( mail, " failed, and retry count was exceeded.\n" );
  1552. X            (void)fprintf( mail, "%s\n", Last_errormsg );
  1553. X            break;
  1554. X        default:
  1555. X            (void)fprintf( mail, " died a horrible death.\n");
  1556. X            (void)fprintf( mail, "%s\n", Last_errormsg );
  1557. X            break;
  1558. X    }
  1559. X    (void) fflush(mail);
  1560. X    (void) fclose(mail);
  1561. X    while ((i = wait(&stat)) > 0 && i != pid){
  1562. X        if(Debug>3)log( XLOG_DEBUG, "sendmail: caught %d, (%s)", i,
  1563. X            Decode_status(&stat));
  1564. X    }
  1565. X    if(Debug>3)log( XLOG_DEBUG, "sendmail: %d finished (%s)",
  1566. X        i,Decode_status(&stat) );
  1567. X}
  1568. END_OF_FILE
  1569. if test 3436 -ne `wc -c <'src/sendmail.c'`; then
  1570.     echo shar: \"'src/sendmail.c'\" unpacked with wrong size!
  1571. fi
  1572. # end of 'src/sendmail.c'
  1573. fi
  1574. if test -f 'src/setup_filter.c' -a "${1}" != "-c" ; then 
  1575.   echo shar: Will not clobber existing file \"'src/setup_filter.c'\"
  1576. else
  1577. echo shar: Extracting \"'src/setup_filter.c'\" \(4073 characters\)
  1578. sed "s/^X//" >'src/setup_filter.c' <<'END_OF_FILE'
  1579. X/***************************************************************************
  1580. X * U. Minnesota LPD Software * Copyright 1987, 1988, Patrick Powell
  1581. X ***************************************************************************
  1582. X * MODULE: Setup_filter.c
  1583. X ***************************************************************************
  1584. X * Revision History: Created Sat Jan  9 16:57:59 CST 1988
  1585. X * $Log:    setup_filter.c,v $
  1586. X * Revision 3.1  88/06/18  09:35:45  papowell
  1587. X * Version 3.0- Distributed Sat Jun 18 1988
  1588. X * 
  1589. X * Revision 2.1  88/05/09  10:10:24  papowell
  1590. X * PLP: Released Version
  1591. X * 
  1592. X * Revision 1.1  88/03/01  11:09:19  papowell
  1593. X * Initial revision
  1594. X * 
  1595. X ***************************************************************************/
  1596. X#ifndef lint
  1597. static char id_str1[] =
  1598. X    "$Header: setup_filter.c,v 3.1 88/06/18 09:35:45 papowell Exp $ PLP Copyright 1988 Patrick Powell";
  1599. X#endif lint
  1600. X
  1601. X/**********************************************************************
  1602. X *Setup_filter(int format; char *filtername )
  1603. X * create the command line to invoke a filter
  1604. X *  format: the format type of the data the filter will be invoked with
  1605. X *           (a single (char) letter identifies the type).
  1606. X *  filtername: an string containing the filter Name and arguments
  1607. X *  prog: address of a pointer which will be set to the program Name
  1608. X *
  1609. X * Actions:
  1610. X *  creates a string which contains the command to invoke a filter.
  1611. X *  The command be of the form:
  1612. X *  filtername arguments \   <- from filtername
  1613. X *      -PPrinter -wwidth -llength -xwidth -ylength [-c] [-iindent] \
  1614. X *        [-Zoptions] [-Cclass] [-Jjob] [-Raccntname] -nlogin -hHost
  1615. X *      -Fformat [affile]
  1616. X *  The 'o' (of filter) only gets the -w, -l, -x, -y and -F options
  1617. X **********************************************************************/
  1618. X
  1619. X#include "lp.h"
  1620. char *add_stropt(), *add_numopt(), *add_chropt();
  1621. X
  1622. char *
  1623. Setup_filter(format, filtername)
  1624. X    int format;
  1625. X    char *filtername;
  1626. X{
  1627. X    static char cmd[BUFSIZ];    /* the command buffer */
  1628. X    char *bp, *ep;        /* buffer pointer and general purpose pointer */
  1629. X
  1630. X    if (!filtername || !*filtername) {
  1631. X        log(XLOG_INFO,"format %c has no filter",format);
  1632. X        return ( (char *)0 );
  1633. X    }
  1634. X
  1635. X    /* set up end of buffer pointer for error detection */
  1636. X    ep = cmd + sizeof(cmd);
  1637. X
  1638. X    /* First copy the filter progname and its fixed args */
  1639. X
  1640. X    bp = estrcp( cmd, filtername, ep );
  1641. X    bp = add_stropt(bp,ep," -P",Printer);
  1642. X    if( PWIDTH[0] == 0 ){
  1643. X        (void)sprintf( PWIDTH, "%d", PW );
  1644. X    }
  1645. X    bp = add_stropt(bp,ep," -w",PWIDTH);
  1646. X    bp = add_numopt(bp,ep," -l",PL);
  1647. X    bp = add_numopt(bp,ep," -x",PX);
  1648. X    bp = add_numopt(bp,ep," -y",PY);
  1649. X
  1650. X    if (format == 'o') {    /* of format */
  1651. X        bp = add_chropt(bp,ep," -F",format);
  1652. X        if( bp == 0 ){
  1653. X            log( XLOG_INFO, "filter command too long '%s'", cmd );
  1654. X            return( 0 );
  1655. X        }
  1656. X        return(cmd);
  1657. X    }
  1658. X
  1659. X    /*
  1660. X     * -PPrinter -wwidth -llength -xwidth -ylength [-c] [-iindent] \
  1661. X     *  [-Zoptions] [-Cclass] [-Jjob] -nlogin -hHost -Fformat [affile]
  1662. X     */
  1663. X    if (format == 'l'){    /* add literal flag */
  1664. X        bp = add_stropt( bp,ep, " -c", "" );
  1665. X    }
  1666. X    if( INDENT[0] ){
  1667. X        bp = add_stropt(bp,ep," -i",INDENT);
  1668. X    }
  1669. X    if( ZOPTS[0] ){
  1670. X        bp = add_stropt(bp,ep," -Z",ZOPTS);
  1671. X    }
  1672. X    if( ACCNTNAME[0] ){
  1673. X        bp = add_stropt(bp,ep," -R",ACCNTNAME);
  1674. X    }
  1675. X    if( CLASSNAME[0] ){
  1676. X        bp = add_stropt(bp,ep," -C",CLASSNAME);
  1677. X    }
  1678. X    if( JOBNAME[0] ){
  1679. X        bp = add_stropt(bp,ep," -J",JOBNAME);
  1680. X    }
  1681. X    bp = add_stropt(bp,ep," -n",LOGNAME);
  1682. X    bp = add_stropt(bp,ep," -h",FROMHOST);
  1683. X    /*
  1684. X     * accounting_filename
  1685. X     */
  1686. X    bp = add_chropt(bp,ep," -F",format);
  1687. X    if( AF && *AF ){
  1688. X        bp = add_stropt(bp,ep," ",AF);
  1689. X    }
  1690. X    if( bp == 0 ){
  1691. X        log( XLOG_INFO, "filter command too long '%s'", cmd );
  1692. X    }
  1693. X    return(cmd);
  1694. X}
  1695. X
  1696. X
  1697. static char *
  1698. add_stropt( s, e, s1, s2 )
  1699. X    char *s, *e, *s1, *s2;
  1700. X{
  1701. X    s = estrcp( s, s1, e );
  1702. X    s = estrcp( s, s2, e );
  1703. X    return( s );
  1704. X}
  1705. X
  1706. static char *
  1707. add_numopt( s, e, s1, n )
  1708. X    char *s, *e, *s1;
  1709. X    int n;
  1710. X{
  1711. X    char b[10];
  1712. X    (void)sprintf(b, "%d", n);
  1713. X    s = estrcp( s, s1, e );
  1714. X    s = estrcp( s, b, e );
  1715. X    return( s );
  1716. X}
  1717. X
  1718. static char *
  1719. add_chropt( s, e, s1, n )
  1720. X    char *s, *e, *s1;
  1721. X    int n;
  1722. X{
  1723. X    char b[2];
  1724. X    b[0]=n; b[1] = 0;
  1725. X    s = estrcp( s, s1, e );
  1726. X    s = estrcp( s, b, e );
  1727. X    return( s );
  1728. X}
  1729. END_OF_FILE
  1730. if test 4073 -ne `wc -c <'src/setup_filter.c'`; then
  1731.     echo shar: \"'src/setup_filter.c'\" unpacked with wrong size!
  1732. fi
  1733. # end of 'src/setup_filter.c'
  1734. fi
  1735. echo shar: End of archive 3 \(of 16\).
  1736. cp /dev/null ark3isdone
  1737. MISSING=""
  1738. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; do
  1739.     if test ! -f ark${I}isdone ; then
  1740.     MISSING="${MISSING} ${I}"
  1741.     fi
  1742. done
  1743. if test "${MISSING}" = "" ; then
  1744.     echo You have unpacked all 16 archives.
  1745.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1746. else
  1747.     echo You still need to unpack the following archives:
  1748.     echo "        " ${MISSING}
  1749. fi
  1750. ##  End of shell archive.
  1751. exit 0
  1752.  
  1753. -- 
  1754. Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
  1755.